package main

import (
	"fmt"
	"runtime"
	"time"
)

var a int

func main() {
	num := runtime.NumCPU()
	runtime.GOMAXPROCS(num)
	ch := make(chan int, 1)
	start := time.Now()
	for i := 0; i < 10000; i++ {
		go func() {
			a = 1 + 1
			ch <- num
		}()
	}
	for i := 0; i < num; i++ {
		fmt.Println(<-ch)
	}
	tc := time.Since(start)
	fmt.Printf("time cost = %v\n", tc)
}
